package g2.routemaster.gui.actions;

import g2.routemaster.gui.wizards.ShowPlayerBonusesWizard;
import g2.routemaster.model.Player;

import org.eclipse.jface.action.Action;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.window.ApplicationWindow;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;

public class ShowBonusesAction extends Action {
   private ApplicationWindow window;
   private Player player;
   public ShowBonusesAction(ApplicationWindow window) {
      this.window = window;
      setText("Show Bonuses");
      setToolTipText("Show Bonuses");
      
      try{
         ImageDescriptor icon = ImageDescriptor.createFromImage(
               new Image(Display.getCurrent(), getClass().getResourceAsStream("/pic/btn_show_bonuses.gif")));
         
         setImageDescriptor(icon); 
      } catch (Exception e){
         System.out.println("Unable to load");
      }
   }
   
   public void setPlayer(Player player){
      this.player = player;
   }
   
   public void run() {
      // Instantiates and initializes the wizard
      ShowPlayerBonusesWizard wizard = new ShowPlayerBonusesWizard();
      wizard.setPlayer(player);
      
      // Instantiates the wizard container with the wizard and opens it
      WizardDialog dialog = new WizardDialog(window.getShell(), wizard);
      dialog.create();
      dialog.open();
   }
}